<%-- 
    Document   : mytest
    Created on : 2012-3-23, 10:59:12
    Author     : xiaoxiao
--%>

<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
                    Class.forName("com.mysql.jdbc.Driver").newInstance();
                    Connection con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/exam", "root", "xiaoxiao");
                    int[] a = new int[5];
                    for (int i = 0; i < 5; i++) {
                        a[i] = 2 + i;
                    }
                    String rr = Arrays.toString(a);
                    //out.println(rr);
                    String result = "";
                    String seprater = ",";
                    for (int i = 0; i < a.length; i++) {
                        result += a[i] + seprater;
                        // out.println(result);
                    }
                    // out.println(result);
                    String[] arr = result.split(",");
                    int[] m = new int[arr.length];

                    for (int i = 0; i < arr.length; i++) {
                        m[i] = Integer.parseInt(arr[i]);
                        //  out.println(arr[i]);
                        //  out.println(m[i]);
                    }
                    String qqq = "1,3,19,20,";
                    String qq = qqq.substring(0, qqq.length() - 1);
                    // out.println(qq);
                    Statement st = con.createStatement();
                    ResultSet rs = st.executeQuery("select * from choiceques where id in(" + qq + ")");
                    while (rs.next()) {
                        // out.println(rs.getString("name"));
                    }



                    Random r = new Random();
                    int array[] = {1, 17, 18, 19, 20, 33, 44};

                    int dan=5;
                    HashSet set = new HashSet();
                    int s = 0;
                    while (s < dan) {
                        if (set.add(array[r.nextInt(array.length)])) {
                            s++;
                        }
                    }
                    Iterator<Integer> it = set.iterator();
                    while (it.hasNext()) {
                        out.println(it.next());
                    }

                    int mm[]=new int[0];
                    out.println(mm.length);
        %>
    </body>
</html>
